﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NReader.Model.RAS;
using NReader.Service;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace XnReader.WinRT.Helper
{
    public class TemplateSelector : DataTemplateSelector
    {
        /// <summary>
        /// 阅读历史模板-在线书籍
        /// </summary>
        public DataTemplate ItemTemplateHistoryOnline { get; set; }

        /// <summary>
        /// 阅读历史模板-本地导入的书籍
        /// </summary>
        public DataTemplate ItemTemplateHistoryLocal { get; set; }

        /// <summary>
        /// 书架模板,本地导入
        /// </summary>
        public DataTemplate ItemTemplateBookcaseLocal { get; set; }

        /// <summary>
        /// 书架模板,在线书籍
        /// </summary>
        public DataTemplate ItemTemplateBookcaseOnline { get; set; }

        /// <summary>
        /// 书架导航模板
        /// </summary>
        public DataTemplate ItemTemplateBookcaseNav { get; set; }
        
        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            if (item == null)
                return null;

            var element = (ArticleInfo) item;
            if (element.online.Equals(1))
                return ItemTemplateBookcaseOnline;
            else
                return ItemTemplateBookcaseLocal;

        //    if (element.GroupName.Equals("最近阅读"))
        //    {
        //        if (element.online.Equals(1))
        //        {
        //            return ItemTemplateHistoryOnline;
        //        }
        //        else
        //        {
        //            return ItemTemplateHistoryLocal;
        //        }
        //    }
        //    else
        //    {
        //        if (element.online.Equals(1))
        //            return ItemTemplateBookcaseOnline;
        //        else
        //            return ItemTemplateBookcaseLocal;
        //    }
        }
    }
}
